<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>  
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合同方案列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">

	<div class="searchArea">
		<form id="searchBar">
			<div class="fieldset1 tabel_col clearFix">
				<div class="fieldBox col_33">
					<div class="label">合同方案名称</div>
					<div class="field">
						<input name="cfgNm" id="cfgNm" type="text" class="ui-textbox"/>
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">支持的事业部</div>
					<div class="field">
						<input name="orgCd" id="orgCd" type="text" ltype="combobox" placeholder="请选择" />
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">支持的项目类型</div>
					<div class="field">
						<input type="text" id="prjTypCd" name="prjTypCd" ltype="combobox" placeholder="请选择"/>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">合同方案编码</div>
					<div class="field">
						<input name="cfgCd" id="cfgCd" type="text" class="ui-textbox"/>
					</div>
				</div>
				<div class="fieldBox col_33" >
					<div class="label">第三方机构</div>
					<div class="field">
						<input type="text" id="insCode" name="insCode" ltype="combobox" placeholder="请选择"/>
					</div>
				</div>
			</div>
		</form>
	</div>
	<div class="btnsBox">
		<span id="searchBtn"  class="sq-button sq-button-round" onclick="search()">查询</span>
		<span id="clearBtn" class="sq-button sq-button-round" onclick="clearSearchBar()">清空</span>
		<span id="addBtn"  class="sq-button sq-button-round" onclick="add()">新增</span>
	</div>
	<div id="ligergrid" class="sq-grid"></div>
</div>

<script type="text/javascript">

    $(function () {
    	// 初始化组件
    	init();
    	// 初始话查询列表
    	initGrid();
    });

    function init(){
		// 事业部选择框
		$.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: "0000", sysCd: "11000",codeGroup:"SYS0031",useDesc:"true" },
				function(json){
					$("#orgCd").ligerComboBox({
						data: json,
						valueField: 'key',
						textField:'value',
						onSelected: function (newvalue){ // 联动
							$.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: newvalue, sysCd: "11000",codeGroup:"PRJ0002" },
									function(data){
										liger.get("prjTypCd").clear();
										liger.get("prjTypCd").set('data',data);
									}
							);
						}
					});
				}
		);
		// 项目类型
		$.getJSON('<%=path%>/system/sysdictionary/getSysDic.do', { orgCd: "0000", sysCd: "11000",codeGroup:"PRJ0002" },
				function(json){
					$("#prjTypCd").ligerComboBox({
						data: json,
						valueField: 'key',
						textField:'value'
					});
				}
		);
		// 第三方机构
		$.getJSON('<%=path%>/system/sysdictionary/getInsCode.do', { orgCd: "0000", sysCd: "11000"},
				function(json){
					$("#insCode").ligerComboBox({
						data: json,
						valueField: 'key',
						textField:'value'
					});
				}
		);
	}

    function initGrid(){
		grid = $("#ligergrid").ligerGrid({
			url: '<%=path%>/cont/prj/initList.do',
			parms:function(){
				return $("#searchBar").ligerForm().getData();
			},
			method: 'get',
			columns: [
				{display: '合同方案编码', name: 'cfgCd'},
				{display: '合同方案名称', name: 'cfgNm'},
				{display: '支持的事业部', name: 'orgNm'},
				{display: '支持的项目类型', name: 'prjTypNm'},
				{display: '第三方机构', name: 'insNm'},
				{display: '操作', 
					render:function (rowdata, rowindex, value, column) {
						var h = "";
						h+="<a class='sq-button-hasicon' href='javascript:void(0);' onclick='review("+rowdata.id+")'>预览</a>";
						h+="<a class='sq-button-hasicon' href='javascript:void(0);' onclick='toModfiyPage("+rowdata.id+")'>修改</a>";
						h+="<a class='sq-button-hasicon' href='javascript:void(0);' onclick='deleteData("+rowdata.id+")'>删除</a>";
						return h;
					}
				}
			],
			root: 'rows',
            record: 'total'
		});
		//grid.setHeight(300);
	}

	function search(){
        grid.reload();
	}

	function clearSearchBar(){
		var form = liger.get("searchBar");
		form.setData({
			cfgNm:"",
			cfgCd:"",
			prjTypCd:"",
			orgCd:"",
			insCode:""
		 });
		
	}

	function add(){
		var timestamp=new Date().getTime();
		Add_navTab('tab_base_cont_add'+timestamp,'添加合同方案','<%=path%>/cont/prj/toAddPage.do');
	}

	function toModfiyPage(id){
		var timestamp=new Date().getTime();
		Add_navTab('tab_base_cont_modify'+timestamp,'修改合同方案','<%=path%>/cont/prj/toModifyPage.do?id='+id);
	}
	
	function review(id){
    	// 校验
    	var timestamp=new Date().getTime();
		Add_navTab('tab_base_cont_review'+timestamp,'合同方案预览','<%=path%>/cont/prj/toReview.do?id='+id);
	}

	function deleteData(dataId){


		$.ligerDialog.confirm('确定删除吗?', function (yes) {
			if(yes){
				var wait_dialog = null;
				$.ajax({
					type: 'post',
					dataType:'json',
					data:{id:dataId},
					url:'<%=path%>/cont/prj/removeById.do',
					beforeSend: function(){
						wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
					},
					success:function(msg){
						wait_dialog.close();
						if(msg.success == 1){
							$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
							grid.reload();//刷新
						}else{
							$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
						}
					}
				});
			}
		});
	}
</script>

</body>
</html>